package com.situ.day9;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class BorderLayoutDemo {
	public static void main(String[] args) {
		// 创建JFrame
		JFrame frame = new JFrame("FlowLayoutDemo");
		JPanel panel = new JPanel();
		frame.add(panel);
		// 设置布局管理器
		panel.setLayout(new BorderLayout());
		//创建组件
		JButton northButton = new JButton("北部");
		JButton southButton = new JButton("南部");
		JButton westButton = new JButton("西部");
		JButton eastButton = new JButton("东部");
		JButton centerButton = new JButton("中部");
		panel.add(northButton, BorderLayout.NORTH);
		panel.add(southButton, BorderLayout.SOUTH);
		panel.add(westButton, BorderLayout.WEST);
		panel.add(eastButton, BorderLayout.EAST);
		panel.add(centerButton, BorderLayout.CENTER);
		// 设置大小,单位是像素
		frame.setSize(500, 500);
		// 设置初始位置
		frame.setLocation(500, 200);
		// 默认是不显示
		frame.setVisible(true);
		// 关闭Frame(设置Frame默认关闭时候的操作，就是当关闭时候退出)
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
}
